<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<div style="padding: 10px;">
	<form class="op-form" id="addForm" name="addForm" method="post">
		<input type="hidden" id="uniqueCodeResult">
		<table>
			<tr>
				<td>类型:</td>
				<td>
					<input class="easyui-validatebox" name="fieldName" required="true" validType="length[1,30]">
				</td>
			</tr>
			<tr>
				<td>类型描述:</td>
				<td>
					<input class="easyui-validatebox" name="name" required="true" validType="length[1,30]">
				</td>
			</tr>
			<tr>
				<td>显示值:</td>
				<td>
					<input class="easyui-validatebox" name="showValue" required="true" validType="length[1,12]">
				</td>
			</tr>
			<tr>
				<td>隐藏值:</td>
				<td>
					<input class="easyui-validatebox" name="fieldValue" required="true" validType="length[1,12]">
				</td>
			</tr>
			<tr>
				<td>排序号:</td>
				<td>
					<input class="easyui-numberbox" name="orderNO" required="false" min="0">
				</td>
			</tr>
			<tr>
				<td>状态:</td>
				<td>
					<select id="status" name="status">
						<option value="0">停用</option>
						<option value="1" selected="selected">在用</option>
					</select>
				</td>
			</tr>
			<tr>
				<td>
					<a id="btnSubmit" href="#" class="easyui-linkbutton" icon="icon-ok" onclick="$('#addForm').submit();">提交</a>
				</td>
				<td>
					<a href="#" class="easyui-linkbutton" icon="icon-cancel" onclick="addForm.reset()">重置</a>
					<a href="#" class="easyui-linkbutton" icon="icon-redo" onclick="$('#dataGrid').show();$('#opPanel').panel('close');">返回</a>
				</td>
			</tr>
		</table>
	</form>
</div>

<script type="text/javascript">
	
	$(document).ready(function(){
		
		$('#addForm').form({
			onSubmit: function(){
				if($(this).form('validate')){
					$("#btnSubmit").linkbutton({disabled:true});
					ajaxAdd();
				}else{
					return false;
				}
			}
		});
	});
	
	function ajaxAdd(){
		var actionURL = "constant.action?command=add";
		var params = $("#addForm").serialize();
			
		jQuery.ajax({
			url: actionURL,
			type: "post",
			cache: false,
			data: params,
			success: function(result){
				if("true" == result){
					$.messager.alert("友情提示", "您的操作成功!", "info", function(){
						$('#tt').datagrid('reload');
						$("#dataGrid").show();
						$("#opPanel").panel("close");
					});
				}else{
					$.messager.alert("友情提示", "您的操作失败!", "error");
				}
			}
		});
	}
</script>